package com.sample.Input;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

public class InputActivity extends Activity implements OnClickListener, OnItemSelectedListener{
	EditText text;
	EditText text3;
	Button confirm;
	Spinner course;
	ArrayAdapter adapter;
	DatePicker date;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        course = (Spinner) findViewById(R.id.spinner1);
		text = (EditText) findViewById(R.id.editText1);
		text3 = (EditText) findViewById(R.id.editText3);
		confirm = (Button) findViewById(R.id.button1);
		date = (DatePicker) findViewById(R.id.datePicker1);
		date.updateDate(2011, 0 , 1);
		confirm.setOnClickListener(this);
		course.setOnItemSelectedListener(this);
		adapter= ArrayAdapter.createFromResource(this, R.array.courseArray, android.R.layout.simple_spinner_item );
		course.setAdapter(adapter);
		
    } 

	public void onClick(View v) {
	int month=date.getMonth()+1;
	String output=text.getText().toString()+", " + course.getSelectedItem().toString() + ", " + month + "/" + date.getDayOfMonth() + "/" + date.getYear() + ", " + text3.getText().toString();	
	Toast.makeText(this, output, Toast.LENGTH_LONG).show();
	}

	public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
			long arg3) {
		Toast.makeText(this, "State changed to " + course.getSelectedItem().toString(), Toast.LENGTH_SHORT).show();
		
	}

	public void onNothingSelected(AdapterView<?> arg0) {
				
	}

}